<%-- 
    Document   : groups
    Created on : Nov 23, 2010, 10:28:55 PM
    Author     : navneet
--%>
<%@page import="com.myapp.global.ConnectionBean"%>
<%@page import="java.sql.ResultSet"%>


<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Web-Dev-Tool by Navneet Kumar</title>
        <meta http-equiv="Content-Language" content="English" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
        <link rel="stylesheet" type="text/css" href="css/style1.css" media="screen" />
        <script type="text/javascript" src="js/javascript4.js" ></script>
        <script type="text/javascript" src="js/javascript_front2.js" ></script>
        <script type="text/javascript">
            var page        = 1;
            var sortby      = 1;
            var sortas      = 1;
            var search      = 0;
            var searchfor   = 0;
            document.onloaded = getoverview();

            function getoverview(){
                var params = '';
                params += '&page='+page;
                params += '&sortby='+sortby;
                params += '&sortas='+sortas;
                params += '&search='+search;
                params += '&searchfor='+searchfor;
                getaddon("ajax/common.jsp?","doOn=groups&doThis=1"+params,"tabs","getoverview_cbk");
            }
            function getoverview_cbk()
            {
                //getObject("neetProcessingDivtabsData").style.display = 'none';
            }
        </script>
    </head>
    <body>
        <div id="wrap">
            <jsp:include page="/WEB-INF/jspf/header.jspf" flush="true" ></jsp:include>
            <div id="right">
                <%
                    if(session.getAttribute("currentUser") != null && session.getAttribute("currentUser").equals("admin"))
                    {
                        if(session.getAttribute("currentAction") != null && session.getAttribute("currentAction").equals("EditGroup"))
                        {
                            String GroupId    = (String)session.getAttribute("GroupId");
                            ConnectionBean cb = new ConnectionBean(true);
                            String Query      = "select id,group_name,description from groups where id="+GroupId;
                            int id = -1;
                            String group_name = "",description = "";
                            cb._executeQuery(Query);
                            if(cb.rs.next()){
                                id          = cb.rs.getInt("id");
                                group_name  = cb.rs.getString("group_name");
                                description = cb.rs.getString("description");
                            }
               %>
                            <h1>Edit Groups</h1>
                            <html:form action="/editGroup">
                                <html:hidden property="id" value="<%=String.valueOf(id) %>" ></html:hidden>
                                <table>
                                    <tbody>
                                        <tr>
                                            <td>Group Name:</td><td><html:text property="groupName" value="<%=group_name %>" /></td>
                                        </tr>
                                        <tr>
                                            <td>Description:</td><td><html:text property="description" value="<%=description %>" /></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="center"><html:submit title='Update Group'>Update Group</html:submit></td>
                                        </tr>
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td colspan="2" align="left">
                                                <span style='color:red'>
                                                    <bean:write name="AGAFB" property="error" ignore="true" /><br/>
                                                    <html:errors property="groupName" /><br/>
                                                </span>
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </html:form>
                <%
                        }
                        else
                        {
                %>
                            <h1>Add Groups</h1>
                            <html:form action="/addGroup">
                                <table>
                                    <tbody>
                                        <tr>
                                            <td>Group Name:</td><td><html:text property="groupName" /></td>
                                        </tr>
                                        <tr>
                                            <td>Description:</td><td><html:text property="description" /></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="center"><html:submit title='Add Group'>Add Group</html:submit></td>
                                        </tr>
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td colspan="2" align="left">
                                                <span style='color:red'>
                                                    <bean:write name="AGAFB" property="error" ignore="true" /><br/>
                                                    <html:errors property="groupName" /><br/>
                                                </span>
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>
                            </html:form>
                <%
                        }
                %>
                        <div id="messageGroups">
                            <% if(session.getAttribute("messageGroupDelete") != null){
                                    out.println(session.getAttribute("messageGroupDelete"));
                                }
                            %>
                        </div>
                        <br/>
                        <div id="tabs">
                            <div id="neetProcessingDivtabsData" style='position:relative;'>
                                <div style='position:absolute; top:0%; left:50%;'>
                                    <img alt=""  src='Image/icon_processing.gif' />
                                </div>
                            </div>
                        </div>

                <%
                }
                else
                {
                %>
                    <jsp:include page="login.jsp" flush="true" ></jsp:include>
                <%
                }
                %>
            </div>
            <div id="left">
                <%
                //if(session.getAttribute("currentUser") != null){
                %>
                    <jsp:include page="/WEB-INF/jspf/left_menu.jspf" flush="true" ></jsp:include>
                <%
                //}
                %>
            </div>
            <div style="clear: both;"> </div>
            <jsp:include page="/WEB-INF/jspf/footer.jspf" flush="true" ></jsp:include>
        </div>
    </body>
</html>